Repository navigation
Claim the shutdown on Quit and the --for expiry, not only on a signal [patch] - #84
Merged
Merged
Conversation
…a signal Only RequestShutdown set shutdownRequested. The Quit item and the --for timer called Shutdown() directly, so after either one the first Ctrl+C or SIGTERM was still cancelled and queued a second shutdown behind a stop action that might be hung; under systemd a --for run then waited out TimeoutStopSec. Quit and the expiry now claim the flag before ending the run, so the next signal gets its default handling, as it does in the console mode. ASignalAfterQuit_IsNotCancelled drives the Quit handler instead of RequestShutdown, and the expiry has its own test. Fixes #80 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW31r4TeF4cogSkLxEi
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #80
What was wrong
Only
TrayApplication.RequestShutdown, the signal path, setshutdownRequested. The Quit item and the--forexpiry timer calledShutdown()directly. After either one, the first Ctrl+C or SIGTERM still found the flag clear, soShutdownSignalscancelled the signal. It then posted a second shutdown to a UI thread that might already be blocked in a hungOnStop. Under systemd, a--forrun then waited outTimeoutStopSecand was SIGKILLed. A--no-trayrun exits on the first SIGTERM.Change
OnQuitRequested) and the expiry (OnDurationExpired, extracted from the timer'sTicklambda) now go through one helper,ShutdownFromUIThread. The helper claimsshutdownRequestedand ends the run only if it won the claim. The next signal then gets its default handling, which is whatRequestShutdown's remarks and A tray run whose UI thread or OnStop hangs can only be stopped with SIGKILL: every repeated Ctrl+C, SIGTERM and SIGHUP is cancelled and does nothing #63/Let a repeated Ctrl+C, SIGTERM or SIGHUP end a run whose shutdown hangs [patch] #66 promise.RequestShutdownis unchanged: check-then-post. It now posts the sameEndRunaction.EndRunis an internal settable action. It defaults to the existingShutdown(), and the tests replace it so they can drive Quit and the expiry without shutting down the test host's dispatcher.Shutdown()a second time. The posted shutdown is already on its way.Tests
ASignalAfterQuit_IsNotCancellednow drivesOnQuitRequested, the real Quit path, instead ofRequestShutdown. It checks that the run ended once and the following SIGHUP hasCancel == false.ASignalAfterTheDurationExpires_IsNotCancelled: the same check for the expiry, followed by a SIGTERM.QuitAfterASignal_DoesNotEndTheRunAgain.scripts/check-tray-signals.shwas not run, because it needs a desktop session.Generated by Claude Code